{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-24T20:11:12.274710Z",
     "start_time": "2019-06-24T20:11:11.784119Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-24T20:15:35.384512Z",
     "start_time": "2019-06-24T20:15:35.357218Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Time</th>\n",
       "      <th>Angry</th>\n",
       "      <th>Disgust</th>\n",
       "      <th>Fear</th>\n",
       "      <th>Happy</th>\n",
       "      <th>Sad</th>\n",
       "      <th>Surprise</th>\n",
       "      <th>Neutral</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0.031923</td>\n",
       "      <td>0.000171</td>\n",
       "      <td>0.044754</td>\n",
       "      <td>0.002690</td>\n",
       "      <td>0.387011</td>\n",
       "      <td>0.000385</td>\n",
       "      <td>0.533067</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.063651</td>\n",
       "      <td>0.000543</td>\n",
       "      <td>0.043723</td>\n",
       "      <td>0.001202</td>\n",
       "      <td>0.323019</td>\n",
       "      <td>0.002580</td>\n",
       "      <td>0.565282</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>0.073205</td>\n",
       "      <td>0.003162</td>\n",
       "      <td>0.035744</td>\n",
       "      <td>0.002605</td>\n",
       "      <td>0.340659</td>\n",
       "      <td>0.003268</td>\n",
       "      <td>0.541357</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>0.093796</td>\n",
       "      <td>0.000732</td>\n",
       "      <td>0.059594</td>\n",
       "      <td>0.005762</td>\n",
       "      <td>0.386414</td>\n",
       "      <td>0.001001</td>\n",
       "      <td>0.452702</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>0.137345</td>\n",
       "      <td>0.003701</td>\n",
       "      <td>0.067732</td>\n",
       "      <td>0.000815</td>\n",
       "      <td>0.583087</td>\n",
       "      <td>0.001200</td>\n",
       "      <td>0.206119</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Time     Angry   Disgust      Fear     Happy       Sad  Surprise   Neutral\n",
       "0     0  0.031923  0.000171  0.044754  0.002690  0.387011  0.000385  0.533067\n",
       "1     1  0.063651  0.000543  0.043723  0.001202  0.323019  0.002580  0.565282\n",
       "2     2  0.073205  0.003162  0.035744  0.002605  0.340659  0.003268  0.541357\n",
       "3     3  0.093796  0.000732  0.059594  0.005762  0.386414  0.001001  0.452702\n",
       "4     4  0.137345  0.003701  0.067732  0.000815  0.583087  0.001200  0.206119"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('prob.csv', header=None, index_col=None).reset_index()\n",
    "df.columns = ['Time', 'Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral']\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-24T20:15:37.242199Z",
     "start_time": "2019-06-24T20:15:37.234834Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=32, step=1)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-24T20:15:37.823364Z",
     "start_time": "2019-06-24T20:15:37.820329Z"
    }
   },
   "outputs": [],
   "source": [
    "import altair as alt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-24T20:42:01.447427Z",
     "start_time": "2019-06-24T20:42:01.260447Z"
    }
   },
   "outputs": [],
   "source": [
    "angry = alt.Chart(df).mark_line(color='orange', strokeWidth=4, interpolate='basis').encode(\n",
    "    x='Time:Q',\n",
    "    y='Angry:Q',\n",
    "    tooltip=[\"Angry\"]\n",
    ")\n",
    "\n",
    "disgust = alt.Chart(df).mark_line(color='red', strokeWidth=4).encode(\n",
    "    x='Time:Q',\n",
    "    y='Disgust:Q',\n",
    "    tooltip=[\"Disgust\"]\n",
    ")\n",
    "\n",
    "\n",
    "fear = alt.Chart(df).mark_line(color='green', strokeWidth=4).encode(\n",
    "    x='Time:Q',\n",
    "    y='Fear:Q',\n",
    "    tooltip=[\"Fear\"]\n",
    ")\n",
    "\n",
    "\n",
    "happy = alt.Chart(df).mark_line(color='blue', strokeWidth=4).encode(\n",
    "    x='Time:Q',\n",
    "    y='Happy:Q',\n",
    "    tooltip=[\"Happy\"]\n",
    ")\n",
    "\n",
    "\n",
    "sad = alt.Chart(df).mark_line(color='black', strokeWidth=4).encode(\n",
    "    x='Time:Q',\n",
    "    y='Sad:Q', \n",
    "    tooltip=[\"Sad\"]\n",
    ")\n",
    "\n",
    "\n",
    "surprise = alt.Chart(df).mark_line(color='pink', strokeWidth=4).encode(\n",
    "    x='Time:Q',\n",
    "    y='Surprise:Q',\n",
    "    tooltip=[\"Surprise\"]\n",
    ")\n",
    "\n",
    "\n",
    "neutral = alt.Chart(df).mark_line(color='brown', strokeWidth=4).encode(\n",
    "    x='Time:Q',\n",
    "    y='Neutral:Q',\n",
    "    tooltip=[\"Neutral\"]\n",
    ")\n",
    "\n",
    "\n",
    "chart = (angry + disgust + fear + happy + sad + surprise + neutral).properties(\n",
    "                    width=1000,\n",
    "                    height=350\n",
    "                )\n",
    "\n",
    "\n",
    "chart.save('chart.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-25T05:56:18.684753Z",
     "start_time": "2019-06-25T05:56:18.676605Z"
    }
   },
   "outputs": [],
   "source": [
    "df_area = pd.concat([df['Time'], df[['Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral']].cumsum()], axis=1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-25T06:01:22.020760Z",
     "start_time": "2019-06-25T06:01:21.885244Z"
    }
   },
   "outputs": [],
   "source": [
    "area_7 = alt.Chart(df_area).mark_area(color='yellow').encode(\n",
    "    x=\"Time:Q\",\n",
    "    y=\"Neutral:Q\",\n",
    "    opacity=alt.value(0.3)\n",
    ")\n",
    "\n",
    "area_1 = alt.Chart(df_area).mark_area().encode(\n",
    "    x=\"Time:Q\",\n",
    "    y=\"Angry:Q\",\n",
    "    opacity=alt.value(0.3)\n",
    ")\n",
    "\n",
    "area_2 = alt.Chart(df_area).mark_area(color='red').encode(\n",
    "    x=\"Time:Q\",\n",
    "    y=\"Disgust:Q\",\n",
    "    opacity=alt.value(0.3)\n",
    ")\n",
    "\n",
    "area_3 = alt.Chart(df_area).mark_area(color='orange').encode(\n",
    "    x=\"Time:Q\",\n",
    "    y=\"Fear:Q\",\n",
    "    opacity=alt.value(0.3)\n",
    ")\n",
    "\n",
    "area_4 = alt.Chart(df_area).mark_area(color='green').encode(\n",
    "    x=\"Time:Q\",\n",
    "    y=\"Happy:Q\",\n",
    "    opacity=alt.value(0.3)\n",
    ")\n",
    "\n",
    "area_5 = alt.Chart(df_area).mark_area(color='purple').encode(\n",
    "    x=\"Time:Q\",\n",
    "    y=\"Sad:Q\",\n",
    "    opacity=alt.value(0.3)\n",
    ")\n",
    "\n",
    "area_6 = alt.Chart(df_area).mark_area(color='pink').encode(\n",
    "    x=\"Time:Q\",\n",
    "    y=\"Surprise:Q\",\n",
    "    opacity=alt.value(0.3)\n",
    ")\n",
    "\n",
    "\n",
    "area = area_7 + area_2 + area_3 + area_4 + area_5 + area_6 + area_2\n",
    "\n",
    "area.save('area.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-25T04:53:14.753578Z",
     "start_time": "2019-06-25T04:53:14.742500Z"
    }
   },
   "outputs": [],
   "source": [
    "df_2 = pd.read_csv('histo.txt')\n",
    "df_3 = pd.read_csv('histo_perso.txt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-25T05:33:38.463708Z",
     "start_time": "2019-06-25T05:33:38.407978Z"
    }
   },
   "outputs": [],
   "source": [
    "hist_1 = alt.Chart(df_2).mark_bar(color='red').encode(\n",
    "    x='density:N',\n",
    "    y='count()'\n",
    ")\n",
    "\n",
    "hist_2 = alt.Chart(df_3).mark_bar(size=30).encode(\n",
    "    x='density:N',\n",
    "    y='count()'\n",
    ")\n",
    "\n",
    "\n",
    "hist=(hist_1 + hist_2).transform_calculate(\n",
    "    density=\"density\"\n",
    ")\n",
    "\n",
    "hist.save('histo.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
